package freedom;
import java.util.Scanner;
/**
 * 本类用于分支结构的复习
 */
public class TestIf04 {
    public static void main(String[] args) {
        testFor01();
        testFor02();
        testFor03();
        testFor04();
        Scanner sc=new Scanner(System.in);
        System.out.println("请输入您的身高数据(单位:m)");
        double height=sc.nextDouble();
        System.out.println("请输入您的体重数据(单位:kg)");
        double weight=sc.nextDouble();
        //计算BMI指数 = 体重/身高*身高
        double bmi=weight/(height*height);
        String result="";
        if (bmi<18.5){
            result="过轻";
        }else if (bmi<=22.9){
            result="正常";
        }else if (bmi<=24.9){
            result="偏胖";
        }else if (bmi<=29.9){
            result="肥胖";
        }else if (bmi<=40){
            result="重度肥胖";
        }else{
            result="极度肥胖";
        }
        System.out.println("您的BMI指数为:"+bmi+",Q属于:"+result);
    }

    //此方法用于实现for循环,打印8,88,888,8888次特定语句
    public static void testFor01(){
        for (int i =0; i <=10000; i++) {
            if (i%10==8||i%100==8||i%1000==8||i%10000==8){
                while (i==8||i==88||i==888||i==8888) {
                    System.out.println(i);break;
                }
            }
        }
        System.out.println("---------------------");
    }
    //1-100以内所有数的和
    public static void testFor02(){
        int sum=0;
        for (int i =1; i <=100 ; i++) {
            sum=sum+i;
        }
        System.out.println("1-100以内所有数的和:"+sum);
        System.out.println("---------------------");
    }
    //1-100以内所有偶数的和
    public static void testFor03(){
        int sum=0;
        for (int i = 1; i <= 100; i++) {
            if(i%2==0){
                sum=sum+i;
            }
        }
        System.out.println("1-100以内所有偶数的和:"+sum);
        System.out.println("---------------------");
    }
    //1-100以内所有奇数的个数
    public static void testFor04(){
        int m=0;
        for (int i = 1; i <= 100; i++) {
            if(i%2!=0){
                m++;
            }
        }
        System.out.println("1-100以内所有奇数的个数:"+m);
        System.out.println("---------------------");
    }



}
